<?php
 /*************************************************\
    TV-Program
    Version: 2.5
    Author: Dmitri M. Furmanoff
    E-mail: furik@mail.ru
    \*************************************************/

    /*************************************************\
    Компонент: Телепрограммы
    Версия: 2.3
    Автор: Дмитрий Фурманов
    E-mail: furik@mail.ru
    \*************************************************/

defined ('_VALID_MOS') or die('Доступ к файлу запрещен.');
$isrem=0;
require_once($mosConfig_absolute_path."/administrator/components/com_tv/config.tv.php");

$SearchString = htmlspecialchars(trim(strtolower($SearchString)), ENT_QUOTES);
if($showanons && $ShowComments)
$qr="SELECT tc.channelname, tc.channellogo, tp.pid, tp.channel, tp.name, ta.about, tp.date, tp.hour, tp.minute
FROM #__tvanons ta
RIGHT JOIN (
#__tvchannels tc
INNER JOIN #__tvprogramms tp ON tc.cid = tp.channel
) ON ( ta.channel = tp.channel ) AND (
ta.date = tp.date
) AND (
ta.minute = tp.minute
) AND (
ta.hour = tp.hour
)
WHERE (LOWER(tp.name) like '%".$SearchString."%' or LOWER(ta.about) like '%".$SearchString."%') AND tc.published=1
ORDER BY tc.ordering, tp.date, tp.order";
else
$qr="SELECT tc.channelname, tc.channellogo, tp.pid, tp.channel, tp.name, tp.date, tp.hour, tp.minute
FROM #__tvchannels tc
INNER JOIN #__tvprogramms tp ON tc.cid = tp.channel
WHERE LOWER(tp.name) like '%".$SearchString."%'  AND tc.published=1
ORDER BY tc.ordering, tp.date, tp.order";


$database->setQuery($qr);
$programms=$database->loadObjectList();
$nc=0;
$dc="";
$i=0;
if(count($programms))
{
echo "<form name=tv_reminder method=post action=".sefRelToAbs("index.php?option=com_tv")."'>";
echo "<table width=100% border=0 cellspacing=1>";
foreach($programms as $programm)
{
if($programm->channel != $nc)
     {
     echo "<tr class=sectiontableheader><td colspan=";
     if($my->id)
        echo "3";
     else
        echo "2";   
     echo ">";
     if(strlen($programm->channellogo))
       echo "<img src='$mosConfig_live_site/$pathlogo/$programm->channellogo' border=0 width=40 height=32 align=\"absmiddle\" vspace=2 />";
     else
       echo "<img src='$mosConfig_live_site/images/blank.png' border=0 width=40 height=32 align=\"absmiddle\" vspace=2 />";
     echo "$programm->channelname</td></tr>\n";
     }
if($programm->date != $dc)
{
     $dat=strtotime($programm->date);
     $adat=getdate($dat);
     $wday= $adat['wday']; 
     $wday=$wday?$wday:7;
     echo "<tr><td align=center colspan=";
     if($my->id)
        echo "3";
     else
        echo "2";   
     echo ">";
     echo "<b>".$a_weekl[$wday-1].",".date('d.m.Y',$dat)."</b>";
     echo "</td></tr>\n";
}
echo "<tr class=sectiontableentry".($i % 2 + 1).">";
if(strlen($filter) && eregi($filter,$programm->name))
  {
  echo "<td width=\"30\"><b>".$programm->hour.":".$programm->minute."</b></td>";
  echo "<td><b>".$programm->name."</b></td>";
  }
else
 {
  echo "<td width=\"30\">".$programm->hour.":".$programm->minute."</td>";
  echo "<td>".$programm->name."</td>";
  }
if($my->id)
{
echo "<td>";
if(strtotime($programm->date)>$mostime)
 {
  echo "<input type=checkbox name=Reminder[] value=".$programm->pid.">";
  $isrem=1;
 }
echo "&nbsp;</td>";
}
echo "</tr>\n";
if($showanons)
 {
  if($programm->about){
    echo "<tr class=sectiontableentry".($i % 2 +1)."><td width=30>&nbsp;</td>";
    echo "<td>".$programm->about."</td></tr>\n";
    }     
 }
$nc=$programm->channel;
$dc=$programm->date;
$i++;
}
echo "</table>";
echo "<input type=hidden name=task value='reminder'>";
if($isrem)
 echo "<right><input type=submit class='button' value="._TV_BUTTONREMINDER."></right>";
echo "</form>";
}
else
 echo _TV_SEARCHNORESULT;

 
// Draw the Back button.
mosHTML::BackButton( $params );

?>
